package etc.com.market;

import java.io.File;
import java.net.URI;
import java.util.Calendar;
import java.util.List;

import etc.com.market.R;
import android.app.Application;
import android.content.Context;
import android.net.ConnectivityManager;
import android.os.ParcelFileDescriptor;

public class MarketSystem extends Application {
	// private List<SchedulerVO>Datetime;

	public static String currentAction;
	
	public String tmpScheduleDate = "";
	
	public String date;
	public List<String> dateinfo;
	// public List<String> getDate() {
	// return date;
	// }
	//
	// public void setDate(List<String> date) {
	// this.date = date;
	// }

	// private SchedulerVO currentTurn;
	// public SchedulerVO currentDateTimeVO;
	private int sequence = 0;
	public int currentThemeIndex;
	// public SermonHomeAct srmHmAct;
	// public CaleandarHomeAct clndrHmAct;
	public int m_srmDtlCrrPgIndx = 1;
	public int m_tmp_srmDtlPgIndx = 1;
	public int m_smDtaRowCount = 0;
	public String[] SermonTitleGrp = { "", "", "", "" };
	public String[] ClndarTitleGrp = { "", "", "", "" };
	public String SermDtlTitle = "";
	public String PraiDtlTitle = "";
	public String FvrDtlTitle = "";
	public long currentTime = Calendar.getInstance().getTimeInMillis();
	private static boolean isOldDBVersion;

	public boolean check(String name) {
		if(name.equals(currentAction)){
			return false;
		}
		currentAction = name;
		return true;
	}
	
	public boolean isOldDBVersion() {
		return isOldDBVersion;
	}

	public void setOldDBVersion(boolean isOldDBVersion) {
		this.isOldDBVersion = isOldDBVersion;
	}

	public long getCurrentTime() {
		return currentTime;
	}

	public void setCurrentTime(long currentTime) {
		this.currentTime = currentTime;
	}

	public int getSmDtaRowCount() {
		return m_smDtaRowCount;
	}

	public void setSmDtaRowCount(int m_smDtaRowCount) {
		this.m_smDtaRowCount = m_smDtaRowCount;
	}

	public int getTmp_srmDtlPgIndx() {
		return m_tmp_srmDtlPgIndx;
	}

	public void setTmp_srmDtlPgIndx(int m_tmp_srmDtlPgIndx) {
		this.m_tmp_srmDtlPgIndx = m_tmp_srmDtlPgIndx;
	}

	// public SchedulerVO getCurrentTurn() {
	// return currentTurn;
	// }

	public int getSrmDtlCrrPgIndx() {
		return m_srmDtlCrrPgIndx;
	}

	public void setSrmDtlCrrPgIndx(int srmDtlCrrPgIndx) {
		m_srmDtlCrrPgIndx = srmDtlCrrPgIndx;
	}

	// public void setCurrentTurn(SchedulerVO currentTurn) {
	// this.currentTurn = currentTurn;
	// }

	public int getSequence() {
		return sequence;
	}

	public void setSequence(int sequence) {
		this.sequence = sequence;
	}

	public ParcelFileDescriptor LoadImageFromWebOperations(String url) {
		try

		{
			URI uri = URI.create(url);
			File file = new File(uri);
			ParcelFileDescriptor parcel = ParcelFileDescriptor.open(file,
					ParcelFileDescriptor.MODE_READ_ONLY);
			return parcel;

		} catch (Exception e) {

			System.out.println("Exc=" + e);

			return null;

		}
		// return null;
	}

	public final static int[] THEMER_ID = { R.drawable.transportation,
			R.drawable.shuttle, R.drawable.parking };

	public static boolean chkWifiStatus(Context ctx) {
		try {
			ConnectivityManager connMgr = (ConnectivityManager) ctx
					.getSystemService(Context.CONNECTIVITY_SERVICE);

			final android.net.NetworkInfo wifi = connMgr
					.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

			final android.net.NetworkInfo mobile = connMgr
					.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);

			if (wifi.isConnected()) {
				// Toast.makeText(this, "Wifi" , Toast.LENGTH_LONG).show();
				return true;
			} else if (mobile.isConnected()) {
				// Toast.makeText(this, "Mobile 3G " ,
				// Toast.LENGTH_LONG).show();
				return true;
			} else {
				// Toast.makeText(this,
				// "No Network! Please check internet connection. " ,
				// Toast.LENGTH_SHORT).show();
				return false;
			}
		} catch (Exception e) {
			String msg = e.getMessage();
		}
		return false;
	}
	// public final static String[] THEM_ID={
	// "file:///data/data/etc.com.church/lib/parking.png",
	// "file:///data/data/etc.com.church/lib/shuttle.png",
	// "file:///data/data/etc.com.church/lib/transportation.png"
	// };

}
